package com.diy.sigmund.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * 服务注册测试
 *
 * @author ylm-sigmund
 * @since 2023/3/28 16:42
 */
@RestController
public class DiscoveryTestController {

    private final RestTemplate restTemplate;

    @Autowired
    public DiscoveryTestController(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    /**
     * http://127.0.0.1:8081/echo/sigmund
     */
    @RequestMapping(value = "/echo/{str}", method = RequestMethod.GET)
    public String echo(@PathVariable String str) {
        return restTemplate.getForObject("http://nacos-spring-cloud-provider-example/echo/" + str, String.class);
    }
}
